package com.ruoyi.web.controller.wfshou;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.system.service.ISysDeptService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wfshou.domain.ProjProcess;
import com.ruoyi.wfshou.service.IProjProcessService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 加工技术类项目Controller
 * 
 * @author zongying
 * @date 2023-06-19
 */
@RestController
@RequestMapping("/wfshou/Projprocess")
public class ProjProcessController extends BaseController
{
    @Autowired
    private IProjProcessService projProcessService;
    @Autowired
    private ISysDeptService deptService;
    /**
     * 查询加工技术类项目列表
     */
    @PreAuthorize("@ss.hasPermi('wfshou:Projprocess:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjProcess projProcess)
    {
        startPage();
        List<ProjProcess> list = projProcessService.selectProjProcessList(projProcess);
        return getDataTable(list);
    }
    @GetMapping("/listAll")
    public TableDataInfo listAll()
    {
        List<SysDept> list = deptService.selectDeptListAll();
        return  getDataTable(list);
    }
    /**
     * 导出加工技术类项目列表
     */
    @PreAuthorize("@ss.hasPermi('wfshou:Projprocess:export')")
    @Log(title = "加工技术类项目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProjProcess projProcess)
    {
        List<ProjProcess> list = projProcessService.selectProjProcessList(projProcess);
        ExcelUtil<ProjProcess> util = new ExcelUtil<ProjProcess>(ProjProcess.class);
        util.exportExcel(response, list, "加工技术类项目数据");
    }

    /**
     * 获取加工技术类项目详细信息
     */
    @PreAuthorize("@ss.hasPermi('wfshou:Projprocess:query')")
    @GetMapping(value = "/{projId}")
    public AjaxResult getInfo(@PathVariable("projId") Long projId)
    {
        return success(projProcessService.selectProjProcessByProjId(projId));
    }

    /**
     * 新增加工技术类项目
     */
    @PreAuthorize("@ss.hasPermi('wfshou:Projprocess:add')")
    @Log(title = "加工技术类项目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjProcess projProcess)
    {
        return toAjax(projProcessService.insertProjProcess(projProcess));
    }

    /**
     * 修改加工技术类项目
     */
    @PreAuthorize("@ss.hasPermi('wfshou:Projprocess:edit')")
    @Log(title = "加工技术类项目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjProcess projProcess)
    {
        return toAjax(projProcessService.updateProjProcess(projProcess));
    }

    /**
     * 删除加工技术类项目
     */
    @PreAuthorize("@ss.hasPermi('wfshou:Projprocess:remove')")
    @Log(title = "加工技术类项目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{projIds}")
    public AjaxResult remove(@PathVariable Long[] projIds)
    {
        return toAjax(projProcessService.deleteProjProcessByProjIds(projIds));
    }
}
